package testes;

import static org.junit.Assert.*;

import java.util.LinkedList;

import junit.framework.Assert;

import org.junit.Ignore;
import org.junit.Test;

import smashed.CycleWorkSpace;
import smashed.Edge;
import smashed.FinishTimeWorkSpace;
import smashed.Graph;
import smashed.RegionWorkSpace;
import smashed.Vertex;

public class Junit {

	@Test
	public void teste01() {
		CycleWorkSpace c = new CycleWorkSpace();
		Assert.assertFalse(c.AnyCycles);
	}
	
	@Test
	public void teste02(){
		CycleWorkSpace c = new CycleWorkSpace();
		Vertex v = new Vertex();
		c.init_vertex(v);
		Assert.assertEquals(Integer.MAX_VALUE, v.VertexCycle);
	}
	
	@Test
	public void teste03(){
		CycleWorkSpace c = new CycleWorkSpace();
		Vertex v = new Vertex();
		c.postVisitAction(v);
		Assert.assertEquals(-1, c.counter);
	}
	
	@Test
	public void teste04(){
		Vertex s = new Vertex(), 
			   e = new Vertex();
		Edge ed = new Edge(s, e, 10);
		Assert.assertSame(s, ed.start);
		Assert.assertSame(e, ed.end);
		Assert.assertEquals(10, ed.weight);
	}
	
	@Test
	public void teste05() {
		Graph g = new Graph();
		Vertex v1 = new Vertex();
		Vertex v2 = new Vertex();
		v1.addAdjacent(v2);
		g.addVertex(v1);
		g.addVertex(v2);
		assertTrue(g.vertices.contains(v1));
		
	}
	
	@Test
	public void teste06() {
		Graph g = new Graph();
		Vertex v1 = new Vertex(), 
			   v2 = new Vertex(), 
			   v3 = new Vertex();
		v1.assignName("Vertex01");
		v2.assignName("Vertex02");
		v3.assignName("Vertex03");
		g.addVertex(v1);
		g.addVertex(v2);
		g.addVertex(v3);
		try {
		assertNotNull(g.findsVertex("Vertex03"));
		} catch (NullPointerException ex) {}
		
	}

	@Test
	public void teste07() {
		Graph g = new Graph();
		Vertex v1 = new Vertex(),
			   v2 = new Vertex();
		g.addAnEdge(v1, v2, 3);
		LinkedList<Object> o = v1.weightsList;
		int i = (int) o.get(0);
		assertEquals(i, 3);
		
	}
	
	@Test
	public void teste08() {
		CycleWorkSpace c = new CycleWorkSpace();
		Graph g = new Graph();
		Vertex v1 = new Vertex(),
			   v2 = new Vertex();
		g.addVertex(v1);
		g.addVertex(v2);
		g.GraphSearch(c);
	}
	
	@Test
	public void teste09() {
		RegionWorkSpace r = new RegionWorkSpace();
		Vertex v = new Vertex();
		r.postVisitAction(v);
		assertEquals(0, v.componentNumber);
	}
	
	@Test
	public void teste10() {
		RegionWorkSpace r = new RegionWorkSpace();
		Vertex v = new Vertex();
		r.init_vertex(v);
		assertEquals(-1, v.componentNumber);
	}

}